//打乱数组   效果没能实现
function luan (arr) {
	arr.sort(function() {
		if (Math.random() > 0.5) {
			return 1;
		}else {
			return -1;
		}
	})	
}
var spans = document.getElementById("parent");
for (var i = 0; i<imgs.length;i++) {
	var span = document.createElement("span");
	span.className = "span1";
	span.num = i;
	span.innerHTML  = '<img src="' + imgs[i] +'" alt="">';
	spans.appendChild(span);

	
}
var arr = [];
var span2 = document.querySelectorAll(".span1");
for (var i = 0; i < span2.length; i++) {
	span2[i].onclick = function (e) {
		var a  =  imgs[e.currentTarget.num]
		span2[e.currentTarget.num].className = "span1 red";
		arr.push(a);
		
	}
}


var Name = document.getElementById("name");
var Content = document.getElementById("content");
Name.onkeyup = function () {
	var  namE = document.getElementById("name").value;
	if (namE.length>0 && namE.length<=15) {

	}else {
		alert("老哥！你复姓吗？")
		Name.value = "";
	}

}

// var heihei = [];
// var heiheia = [];
var but = document.getElementById("play");
var out = document.querySelector(".abc");
var moo = [];
var j = 0;

but.onclick = function() {
	var name = document.getElementById("name").value;
	var content = document.getElementById("content").value;
	if (arr.length >= 1) {
		if (isNaN(name) && isNaN(content)) {
			var qdiv = document.createElement("div");
			qdiv.className = "q";
			out.appendChild(qdiv);
			var ldiv = document.createElement("div");
			ldiv.className = "l";
			ldiv.num = j++;
			console.log(ldiv.num);
			qdiv.appendChild(ldiv);
			var spanm = document.createElement("span");
			spanm.className = "p";
			spanm.innerHTML = "删除";
			ldiv.appendChild(spanm);
			var wdiv = document.createElement("div");
			wdiv.className = "w";
			qdiv.appendChild(wdiv);
			var img1 = document.createElement("img");
			img1.src = arr[arr.length - 1];
			wdiv.appendChild(img1);
			arr.shift();
			var ediv = document.createElement("div");
			ediv.className = "e";
			qdiv.appendChild(ediv);
			var spanq= document.createElement("span");
			spanq.innerHTML = name;
			spanq.className = "t";
			ediv.appendChild(spanq);
			var bdiv = document.createElement("div");
			bdiv.className = "b";
			ediv.appendChild(bdiv);
			var p2 = document.createElement("p");
			p2.innerHTML = content;
			bdiv.appendChild(p2);
			var rdiv = document.createElement("div");
			rdiv.className = "r";
			qdiv.appendChild(rdiv);
			var spanw = document.createElement("span");
			spanw.className = "y";
			spanw.innerHTML = guolu(m1) + "月" + guolu(d1) +"日" + "&nbsp&nbsp" + guolu(h1) +":" + guolu(min1);
			rdiv.appendChild(spanw);
			var heihei  = document.querySelectorAll(".q");
			console.log(heihei)
			var heiheia = document.querySelectorAll(".l");
			console.log(heiheia)
			for (var i = 0; i < heiheia.length; i++) {
				heiheia[i].onclick = function (e) {
				var g = e.currentTarget.num;

				console.log(g)
				heihei[g].remove();
				heihei.splice(g,1);
									
	}
}
		}

	}else {
		alert('请选择头像框');
	}
	
}


var length = document.getElementById("length");
var k2 = document.getElementById("content");

k2.onkeyup = function () {
	var k1 = document.getElementById("content").value.trim();
	var  len  = k1.length;
	var h1 = 140 - len;
	if (h1>=0) {
		length.innerHTML = h1;
	}else {
		alert('大哥！别别比！别叨叨');
		length.innerHTML = 140;
		k2.value = "";

	}

}
var time = new Date();
var m1 = time.getMonth()
var m2 = m1 +=1;
console.log(m2);
var d1 = time.getDate();
console.log(d1);
var h1 = time.getHours();
console.log(h1);
var min1 = time.getMinutes();
console.log(min1);


function getTime() {
	var time = new Date();
	var m1 = time.getMonth();
	var m2 = m1+=1;
	var d1 = time.getDate();
	var h1 = time.getHours();
	var min1 = time.getMinutes();
}
setInterval(getTime,1000);


function guolu(n) {
	if (n >= 10) {
		return n ;
	}else {
		return "0" + n;
	}
}











